package com.sgb.kjwl.model.entity.self

import android.text.TextUtils
import com.swgk.core.util.DateUtils
import java.io.Serializable
import java.util.*

class OrganizationAuthEntity (
      var id : String = "",//id 新增不用传id,编辑需要传id(string类型)
      var businessScope : String = "",//经营范围
      var card : String = "", //身份证
      var cityNo : String = "", //市级编号
      var cityName : String = "",//市级名称
      var codeCertificatePic : String = "",//统一社会信用代码证书
      var creditCode : String = "", //统一社会信用代码
      var detailedAddress : String = "",//统一社会信用代码证书详细地址
      var districtNo : String = "", //区级编号
      var districtName : String = "",//区级名称
      var institutionalTypeName : String = "", //机构类型名称
      var institutionalTypeNo : String = "", //机构类型no
      var legalPerson : String = "", //法定代表人
      var longTime : Int = 0, //0默认不是长期，1代表长期
      var organizationName : String = "", //政府/单位名称
      var organizationNo : String = "", //政府/单位no
      var provinceNo : String = "", //省级编号
      var provinceName : String = "",//省级名称
      var registerDate : String = "", //注册时间
      var registerMoney : String = "", //注册资金
      var registrationDepartment : String = "", //登记管理部门
      var status : Int = 1, //1 待审核 2 审核未通过  3 审核通过 4 无需审核 //默认待审核
      var userName : String = "", //用户姓名
      var userPhone : String = "", //用户手机号
      var validityDate : String = "", //有效期
      var reason : String = "",//拒绝理由
      var realNameUserDTO : TeamAuthEntity.RealNameUserDTO ?= null
        ): Serializable {

      fun getCreateTime(): String {
            var createTime = ""
            if (TextUtils.isEmpty(registerDate)) {
                  return createTime
            }
            createTime = try {
                  val time = registerDate.toLong()
                  DateUtils.timestampTo13DateNos(time)
            } catch (e: Exception) {
                  registerDate
            }
            return createTime
      }

      fun getCreateDate(): Date ?{
            var createDate : Date ?= null
            if (TextUtils.isEmpty(registerDate)) {
                  return createDate
            }
            createDate = try {
                  val time = registerDate.toLong()
                  Date(time)
            } catch (e: Exception) {
                  null
            }
            return createDate
      }

      fun getValidityTime(): String {
            var validityTime = ""
            if (TextUtils.isEmpty(validityDate)) {
                  return validityTime
            }
            validityTime = try {
                  val time = validityDate.toLong()
                  DateUtils.timestampTo13DateNos(time)
            } catch (e: Exception) {
                  validityDate
            }
            return validityTime
      }

      fun getValidityDates(): Date?{
            var validityDates : Date ?= null
            if (TextUtils.isEmpty(validityDate)) {
                  return validityDates
            }
            validityDates = try {
                  val time = validityDate.toLong()
                  Date(time)
            } catch (e: Exception) {
                  null
            }
            return validityDates
      }

      fun getLongTimeStr() : String {
            if (longTime == 1) {
                  return "长期"
            }
            return ""
      }

      fun setLongTimeStr(str: String) {
            longTime = if (str == "长期") {
                  1
            } else {
                  0
            }
      }

      fun getAddress() : String{
            return provinceName + cityName + districtName + detailedAddress
      }

}